package com.springsecurity.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.springsecurity.dao.weibo.WeiboUserDAOI;
import com.springsecurity.entity.weibo.User;
import com.springsecurity.service.impl.weibo.WeiboUserServiceI;

public class WeiboUserServiceImpl implements WeiboUserServiceI {

	@Autowired
	private WeiboUserDAOI weiboUseDao;
	@Override
	public long register(String email, String nickname, String password) {
		return weiboUseDao.register(new User(null,email,nickname,password,null));
	}

	@Override
	public boolean login(String email, String password) {
		return weiboUseDao.login(email, password);
	}

	@Override
	public List<User> newUserList(int limit) {
		List<Long> ids=weiboUseDao.newUserList(limit);
		List<User> users=new ArrayList<>(ids.size());
		for(Long id:ids){
			users.add(weiboUseDao.getUser(id));
		}
		return users;
	}

}
